package com.myteam.fugaocrm.sqldb.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.myteam.fugaocrm.modle.FgCustomer;
import com.myteam.fugaocrm.modle.FgStaff;

/**
 * 客户联系人Mapper
 * @author BZX
 */
public interface FgCustomerMapper {

	/** 查询全部客户联系人 */
	@Select(
			"select customer.*,company.customer_company_name "
		  + "from fg_customer customer "
		  + "left join fg_customer_company company on customer.customer_company_id = company.customer_company_id "
		  + "where customer.is_delete = 0"
		  )
	public List<FgCustomer> all();
	
	/** 根据客户公司id查询全部客户联系人 */
	@Select(
			"select * "
		  + "from fg_customer "
		  + "where "
		  + "is_delete = 0 "
		  + "and customer_company_id = #{companyId}"
		  )
	public List<FgCustomer> allByCustomerCompanyId(@Param("companyId") Integer companyId);
	
	/** 删除一个客户联系人 */
	@Select("update fg_customer set is_delete = 1 where customer_id = #{customerId}")
	public void deleteOne(@Param("customerId") Integer customerId);
	
	/** 注册一个员工 */
	@Insert("INSERT into fg_customer(customer_company_id,customer_name,customer_mobile,customer_email,title,created_date,created_user) VALUES(#{customerCompanyId},#{customerName},#{customerMobile},#{customerEmail},#{title},#{createdDate},#{createdUser})")
	public void insert(Map<String, Object> params);
	
	/** 修改一个员工 */
	@Select("update fg_customer set customer_company_id=#{customerCompanyId},customer_name=#{customerName},customer_mobile=#{customerMobile},customer_email=#{customerEmail},title=#{title},modified_user=#{modifiedUser},modified_date=#{modifiedDate} where customer_id = #{customerId}")
	public void update(Map<String, Object> params);
	
	/** 根据ID查询客户 */
	@Select("SELECT * FROM fg_customer WHERE customer_id = #{customerId}")
	public FgCustomer selectById(@Param("customerId") Integer customerId);
	
}
